package program

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method 'GET'
        url value(consumer(regex('/api/programs/\\d+/tutors/\\d+/students')),
                producer('/api/programs/1/tutors/1/students'))
        headers {
            contentType(applicationJsonUtf8())
        }
    }
    response {
        status 200
        body("""
            [{
                "id": 1,
                "tutorId": 1,
                "programId": 1,
                "studentId": 1
            }]
        """)
        bodyMatchers {
            jsonPath('$.[*]',byType())
            jsonPath('$.[*].id',byRegex(number()))
            jsonPath('$.[*].tutorId',byRegex(number()))
            jsonPath('$.[*].programId',byRegex(number()))
            jsonPath('$.[*].studentId',byRegex(number()))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }

}